﻿<html DIR="LTR" xmlns:tool="http://www.microsoft.com/tooltip" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ddue="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:MSHelp="http://msdn.microsoft.com/mshelp">
  <head>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8" />
    <META NAME="save" CONTENT="history" />
    <title>getConnection Method (java.lang.String, java.lang.String)</title>
    
    <link rel="stylesheet" type="text/css" href="../local/Classic.css">
      
    </link>
    
    <script src="../local/script.js">
      
    </script><script src="../local/script_main.js">&amp;nbsp;</script>
  </head>
  <body>
    <!--Topic built:12/06/2007 20:50:20-->

    
    
    
    
    
    
    
    
    
    <div id="header">
      <table width="100%" id="topTable"><tr>
          <td align="left">
            <span id="headerBold">getConnection Method (java.lang.String, java.lang.String)</span>
          </td>
          <td align="right">
            
          </td>
        </tr></table>
      
      
      
    </div>
    <div id="mainSection">
      
        
        
		<font color="DarkGray"><!-- [This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]<br/>[Documentation built on $$TIMESTAMP$$]  --> </font> <p /> <p />
	
        <div id="introductionSection" class="section">
    <p>Tries to establish a connection with the data source that this <a href="097434fd-2b74-411c-a5ed-eba04481dde5.htm">SQLServerDataSource</a> object represents by using the given user name and password.</p>
  </div><h1 class="heading">语法</h1><div id="syntaxSection" class="section"><div class="sampleCode"><span codeLanguage="other"><pre>
public java.sql.Connection <b>getConnection</b>(java.lang.String <i>username</i>,
                                         java.lang.String <i>password</i>)</pre></span></div><h1 class="heading">参数</h1><div id="parametersSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">
        <i>username</i>
      </p>
      <p xmlns="">A<b> String </b>that contains the user name.</p>
      <p xmlns="">
        <i>password</i>
      </p>
      <p xmlns="">A<b> String </b>that contains the password.</p>
    </content>
  </div></div><h1 class="heading">返回值</h1><div id="returnValueSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">A <a href="937292a6-1525-423e-a2b2-a18fd34c2893.htm">SQLServerConnection</a> object.</p>
    </content>
  </div><h1 class="heading">异常</h1><div id="exceptionsSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">java.sql.SQLException</p>
    </content>
  </div><h1 class="heading">备注</h1><div id="remarksSection" class="section" name="collapseableSection">
    <content xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5">
      <p xmlns="">This <b>getConnection</b> method is specified by the <b>getConnection</b> method in the javax.sql.DataSource interface.</p>
      <p xmlns="">Calling the <b>getConnection</b> method with a non-null user name or password will replace the user name and password properties that are set on the <b>SQLServerDataSource</b> class when initializing the <b>SQLServerConnection</b> object. For example, if the caller has called <a href="d2ea7906-2d10-438d-aa51-f576eea923c7.htm">setUser</a> and <a href="0db06631-5e68-488c-a9f1-6e5052c0759d.htm">setPassword</a> on the data source, and then calls <b>getConnection</b> and supplies a non-null user name or a non-null password, the user name and password set by <b>setUser</b> and <b>setPassword</b> will be replaced by the user name and password passed into <b>getConnection</b>. </p>
      <div style="margin: .5em 1.5em .5em 1.5em" xmlns=""><b>注意：</b>
        The user name and password that are set inside the URL by using a call to the <a href="bea70100-ac98-4625-8748-ef7cc0b111ea.htm">setURL</a> method will not be changed in this case.<p />
      </div>
    </content>
  </div><span id="seeAlsoSpan"><h1 class="heading">另请参见</h1></span><div id="seeAlsoSection" class="section" name="collapseableSection"><a href="097434fd-2b74-411c-a5ed-eba04481dde5.htm">SQLServerDataSource Class</a><br /><a href="a15ee185-f433-4915-9c75-5ebd90c758fd.htm">getConnection Method (SQLServerDataSource)</a><br /><a href="fac054f1-60dc-4261-bc1b-ed70d1ceb85f.htm">SQLServerDataSource Methods</a><br /><a href="7e749bc5-d765-4864-be2b-7822d4c20c09.htm">SQLServerDataSource Members</a><br /><br />
		
		<b>
			
			
		</b>
	</div><!--[if gte IE 5]>
			<tool:tip element="seeAlsoToolTip" avoidmouse="false"/><tool:tip element="languageFilterToolTip" avoidmouse="false"/><tool:tip element="roleInfoSpan" avoidmouse="false"/>
		<![endif]-->
      <div id="footer" class="section">
        
		<hr />  <span id="fb" class="feedbackcss"> </span> 
		<a href="9bad553b-9e70-4696-8499-2e35f772a1e0.htm">
			
			© 2007 Microsoft Corporation。保留所有权利。
		</a>
 	
	
      </div>
    </div>
  </body>
</html>